 var id = getvl("id");
 var shopids="";
$(function(){
	 if(id!=''){
	 	
	 	$("#jubao").attr("href","2.6.1jubao.html?id="+id);
	 	  $.ajax({
        url: urlcore + "/api/comment/getCommentByCommentLevel?shopId="+id,
        type: "get",
        dataType: 'json',
        contentType: "application/json;charset=utf-8",
        success:function(data){
         console.log(data)
            if (data.success == true) {
           
            $("#shumu").html(data.data.Sun+"条评价");      
            		
            } else if (data.code == 'OVERTIME'){
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href="1.0.0denglu.html";
                }
            } else {
                alert(data.msg);
            }
        },
        error:function() {
            alert("error");
        }
    });
	 	  
		$.ajax({
        url: urlcore + "/api/shopInfo/selectagno1?shopId="+id,
        type: "get",
        dataType: 'json',
        contentType: "application/json;charset=utf-8",
        success:function(data){
					console.log(data)
            if (data.success == true) {
            	var da =data.data;
            	var dianpuxinxi='<dl class="clearfix">'+
		'<dt>'+
			'<img onerror="errorImg(this)" src="'+da.headImg+'" />'+
			'<div>'+da.storeName+'</div>'+
		'</dt>'+
		'<dd class="dianpu_guanzhu_title">'+
		  '<ul class="clearfix">'+
		  '<li><div class="fensi"><p>粉丝数&nbsp;</p><span style="margin-left:10px;">|</span></div>'+
			'<p>'+da.fans+'</p></li>'+
		  '<li><div class="fensi"><p>复购率&nbsp;</p><span>|</span></div>'+
			'<p>'+da.rebuyRate+'%</p></li>'+
		  '<li><p>销量&nbsp;</p>'+
			'<p>'+da.saleNumber+'</p></li>'+
		  '</ul>'+
		'</dd>'+
		'<dd class="dianpu_guanzhu_guanzhu jg_guanzhu" onclick="guanzhu(this)" id="guanzhu">关注</dd>'+
	  '</dl>';
	          $("#dianpuxinxi").append(dianpuxinxi);      
							 var storeLevel2="";//店铺等级
							 var strt="";
               if(da.storeLevel==1){
               	storeLevel2="普通店铺";
               strt="images/pai03.png";
               }else if(da.storeLevel==2){
               	 storeLevel2="银牌店铺";
               	 	 strt="images/pai02.png";
               }else if(da.storeLevel==3){
               	  storeLevel2="金牌店铺";
               	  	strt="images/pai01.png";
               }
                var imgss="";
              var  creditLevel=da.creditLevel;
                 if(creditLevel<=5){
                  	  for(var i=0;i<creditLevel;i++){
                      imgss+='<img width="20" height="20" src="images/aixin.png"/>';   
                  }
                  }else if(creditLevel<=10){
                  	var credit=creditLevel-5;
                  	  for(var i=0;i<credit;i++){
                 imgss+='<img width="20" height="20" src="images/zuan.png"/>';
                  }
             
                  }else if(creditLevel<=15){
                  	var credit=creditLevel-10;
                  	 for(var i=0;i<credit;i++){
                  imgss+='<img width="20" height="20" src="images/guan.png"/>';
                  }
                  }
                  
                  
           /*	var gmtDatetime = new Date().pattern("yyyy-MM-dd");*/
				 var arename= da.tradeArea.areaName==null?"":da.tradeArea.areaName;
            	var ziliao=
									'<li>店铺等级<span><img src="'+strt+'" width="22" height="22" />'+storeLevel2+'</span></li>'+
									'<li>信誉等级<span>'+imgss+'</span></li>'+
									'<li>所在市场<span>'+arename+'</span></li>'+  //商圈
									'<li>开店时间<span>'+da.gmtDatetime+'</span></li>'+ //开店时间
									'<li>诚信保证金<span style="margin-left:-15px;">'+da.bondMoney+'元</span></li>'+
									'<li>店铺押金<span style="margin-left:-5px;">'+da.shopDeposit+'元</span></li>'+
									'<li>详细地址<span style="margin-left:-5px;">'+da.address+'</span></li>';
            	$("#ziliao").append(ziliao);
							// 商家服务
            	var koko='';
               if(da.serviceLevel>0){
								 koko+='<img src="images/star.png"/>'
							 }else{
                  koko+='<img src="images/star01.png"/>'
							 }
							 if(da.serviceLevel>1){
								 koko+='<img src="images/star.png"/>'
							 }else{
								 koko+='<img src="images/star01.png"/>'
							 }
							 if(da.serviceLevel>2){
								 koko+='<img src="images/star.png"/>'
							 }else{
								 koko+='<img src="images/star01.png"/>'
							 }
							 if(da.serviceLevel>3){
								 koko+='<img src="images/star.png"/>'
							 }else{
								 koko+='<img src="images/star01.png"/>'
							 }
							 if(da.serviceLevel>4){
							 	koko+='<img src="images/star.png"/>'
							 }else{
							 	koko+='<img src="images/star01.png"/>'
							 }
              // 商品品质
            	var fafa='';
							if(da.serviceLevel>0){
								fafa+='<img src="images/star.png" />';
							}else{
								fafa+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>1){
								fafa+='<img src="images/star.png" />';
							}else{
								fafa+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>2){
								fafa+='<img src="images/star.png" />';
							}else{
								fafa+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>3){
								fafa+='<img src="images/star.png" />';
							}else{
								fafa+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>4){
							fafa+='<img src="images/star.png" />';
							}else{
							fafa+='<img src="images/star01.png"/>'
							}
            	// 物流服务
            	var dy='';
							if(da.serviceLevel>0){
								dy+='<img src="images/star.png" />';
							}else{
								dy+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>1){
								dy+='<img src="images/star.png" />';
							}else{
								dy+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>2){
								dy+='<img src="images/star.png" />';
							}else{
								dy+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>3){
								dy+='<img src="images/star.png" />';
							}else{
								dy+='<img src="images/star01.png"/>'
							}
							if(da.serviceLevel>4){
							dy+='<img src="images/star.png" />';
							}else{
							dy+='<img src="images/star01.png"/>'
							}
            	shopids=da.id;
            	
            	var shangjiafuwu=
            		'<ul>'+
									'<li>'+
										'<span>商家服务</span>'+koko+'</li>'+
									'<li>'+
										'<span>商品品质</span>'+fafa+'</li>'+
									'<li>'+
										'<span>物流服务</span>'+dy+'</li>'+
								'</ul>'+
		            '<h6>好评率:<span>'+da.praiseRate+'%</span></h6>';
            	$("#shangjiafuwu").append(shangjiafuwu); //商家服务
            
               var jieshao='<p>';
               if(da.shopNotice==null || da.shopNotice==""){
               jieshao+=	'</p>';
               }else{
               	jieshao+=da.shopNotice+'</p>';
               }
               wxselectfocusshop(da.id);
               $("#jieshao").append(jieshao);
                 // wxselectfocusshop(id);
                 $(function(){
	//关注
	 $('.jg_guanzhu').on('click',function(){		
		if($(this).html() == "关注" ){
			$(this).html("取消").css("background","#ccc");
			
		}else{
			$(this).html("关注").css("background","#FD900F");
				
		}
		
	});	
})
                  
            } else if (data.code == 'OVERTIME'){
                var thisUrl = window.location.href;
                if (thisUrl.indexOf('login.html') <= -1) {
                    top.window.location.href="1.0.0denglu.html";
                }
            } else {
                alert(data.msg);
            }
        },
        error:function() {
            alert("error");
        }
    });
	 	  
	 }else{
	 	alert("无有效值传入...");
	 }
});

function guanzhu(te){
	
	if(uuuuid!=''){
		if($(te).html() == "关注" ){
				  $.ajax({
		url: urlcore + "/api/focusShop/update33", 
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			userId:uuuuid,
			shopId:shopids,
		 	status:1
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				var a=window.location.href;
				window.location.href=a;
			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			alert("error");
		}
	});
			
		}else{
			  $.ajax({
		url: urlcore + "/api/focusShop/update33", 
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			userId:uuuuid,
			shopId:shopids,
		 	status:2
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
             var a=window.location.href;
				window.location.href=a;
			} else if(data.code == 'OVERTIME') {
				var thisUrl = window.location.href;
				if(thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href = "login.html";
				}
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			alert("error");
		}
	});
				
		}
		}
}


//查询是否关注过该店铺
   function  wxselectfocusshop(shopIasds){
  	
		   if(uuuuid!=""){
		$.ajax({
 url: urlcore + "/api/focusShop/wxselectfocusshop?userId="+uuuuid+"&shopId="+shopIasds,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					   if(data.data==null){
					   
					  $("#guanzhu").html("关注").css("background","#FD900F");
					   
					   }else{
					   	     if(data.data.status==1){
           	$("#guanzhu").html("已关注").css("background","#FD900F");
					   	     }else if(data.data.status==2){
	         $("#guanzhu").html("关注").css("background","#FD900F");
					   	     }
					   	     
					   }
					   $(function() {
					   	//关注
	$('.jg_guanzhu').on('click',function(){		
		if($(this).html() == "关注" ){
			$(this).html("已关注").css("background","#FD900F");
		}else{
			$(this).html("关注").css("background","#FD900F");
		}
		
	});	
					   })
					   
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		   
		   }else{
		   	
		$("#guanzhu").html("已关注").css("background","#FD900F");
		   
		   }
   }
   



